package com.emex.app.stuff.security.ui;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 * Label with picture and watemark text
 * 
 * @author Sergey Karavaev
 */
public class VersionLabel extends JLabel
{
	private static final long serialVersionUID = 1L;
	private String version;

        /**
         * Constructor
         * @param topImage picture
         * @param version watemark text
         */
	public VersionLabel(ImageIcon topImage, String version)
	{
		super(topImage);
		this.version = version;
	}

	@Override
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		FontMetrics fm = g.getFontMetrics();
		int w = fm.stringWidth(version) + 16;
		Color oldColor = g.getColor();
		g.setColor(Color.GRAY);
		g.drawString(version, getLocation().x + getWidth() - w, getLocation().y + getHeight() - 4);
		g.setColor(oldColor);
	}
}
